<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="wf" uri="/augurit-wf"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="${ctx}/gzcgwsp/resources/css/common-ui.css" rel="stylesheet" type="text/css" />

<!-- dwr libs -->
<script type='text/javascript' src="${ctx}/dwr/engine.js"></script>
<script type='text/javascript' src="${ctx}/dwr/util.js"></script>
<script type='text/javascript' src="${ctx}/dwr/interface/FileUploadCntl.js"></script>

<script src="${ctx}/gzcgwsp/resources/js/YwUtil.js" type="text/javascript"></script>

<script src="${ctx}/gzcgwsp/resources/js/YwEnterprise.js" type="text/javascript"></script>
<script src="${ctx}/gzcgwsp/resources/js/clxx.js" type="text/javascript"></script>
<script src="${ctx}/gzcgwsp/jzfqwczz/YwYnJzfqwczcJbxx/js/selectUser.js" type="text/javascript"></script>
<script type="text/javascript">
var saveAndSendFlag = undefined;

$(document).ready(function(){
  $('form[0]').ajaxForm({
    dataType: 'json', 
    success: wfBusSaveCallback
  });
});



function wfBusSaveCallback(result){
	var success = window.updateLayoutAfterWfBusSave(result, false);
	
	if(success){
     if (result && result.form) {
      WF_CONFIG.masterEntityKey = result.form.id;
      document.forms[0].id.value = result.form.id;
      document.forms[0].qyid.value = result.form.qyid;
      document.forms[0].acceptNo.value = result.form.acceptNo;
      document.forms[0].acceptNo_.value = result.form.acceptNo;      
      document.getElementById('sjcl_iframe').src = '${ctx}/yw-com-sjcllist!ywList.action?tplcode=${templateCode}&ajid=' + result.form.id + '&qyid=' + result.form.qyid;
      
      if (Ext.getCmp('sjclPanel')) Ext.getCmp('sjclPanel').setDisabled(false);
      if (Ext.getCmp('gisPanel')) Ext.getCmp('gisPanel').setDisabled(false);
      if (Ext.getCmp('WF_PRINT')) Ext.getCmp('WF_PRINT').setDisabled(false);
      if (Ext.getCmp('clxxPanel')) Ext.getCmp('clxxPanel').setDisabled(false);
      saveOpinion();
    }
    
    if(saveAndSendFlag == 'wfBusSaveAndSend') {
      var toolbar = Ext.getCmp('WF_TOOLBAR');
      if(toolbar) toolbar.wfSend();
    }
    if(saveAndSendFlag == 'wfBusSave') {
      alert('保存成功！');
    }
    if(saveAndSendFlag == 'wfBusSj') {
      if (opener.refresh) opener.refresh();
      Ext.getCmp('YslSjBtn').setDisabled(true);
      Ext.getCmp('YslTuihBtn').setDisabled(true);
      alert('收件成功！');
    }
    if(saveAndSendFlag == 'wfBusYslTuih') {
      if (opener.refresh) opener.refresh();
      window.close();
    }
  }
	
	/**if(success){
		document.forms[0].id.value = result.form.id;
		
		document.forms[0].acceptNo.value = result.form.acceptNo;
    	document.forms[0].acceptNo_.value = result.form.acceptNo;
	}

    if(saveAndSendFlag == 'wfBusSaveAndSend'){
        var toolbar = Ext.getCmp('WF_TOOLBAR');
        if(toolbar)
			toolbar.wfSend();
	}else
		alert('保存成功！');
		*/
}

function wfBusSaveAndSend(templateCode, taskInstDbid){
  saveAndSendFlag = 'wfBusSaveAndSend';
  if(validateSend()){
    $('form[0]').attr('action', '${ctx}/yw-yn-jzfqwczc-jbxx-qx!wfBusSave.action?templateCode='+templateCode+'&taskInstDbid='+taskInstDbid);
    $('form[0]').submit();
    if (Ext.getCmp('WF_SAVEANDSEND')) Ext.getCmp('WF_SAVEANDSEND').setDisabled(true);//设置发送按钮不可用
  }
}

function wfBusSave(templateCode,taskInstDbid){
  if (Ext.getCmp('WF_SAVEANDSEND')) Ext.getCmp('WF_SAVEANDSEND').setDisabled(false);//恢复发送按钮可用
  saveAndSendFlag = 'wfBusSave';
  if(validateForm()){
    $('form[0]').attr('action', '${ctx}/yw-yn-jzfqwczc-jbxx-qx!wfBusSave.action?templateCode='+ templateCode+'&taskInstDbid='+taskInstDbid);
    $('form[0]').submit();
  }
}

function wfBusSj() {
  saveAndSendFlag = 'wfBusSj';
  if(validateForm()){
    $('form[0]').attr('action', '${ctx}/yw-yn-jzfqwczc-jbxx-qx!wfBusSave.action?templateCode='+WF_CONFIG.templateCode+'&isYsl=1');
    $('form[0]').submit();
  }
}

function wfBusYslTuih() {
  saveAndSendFlag = 'wfBusYslTuih';
  if(validateForm()){
    $('form[0]').attr('action', '${ctx}/yw-yn-jzfqwczc-jbxx-qx!wfBusYslTuih.action?templateCode='+WF_CONFIG.templateCode+'&isYsl=1');
    $('form[0]').submit();
  }
}

function CreateDoc(){
  var win = new Ext.ux.wf.WfSelRedHeadFile({
    url: '/yw-yn-jzfqwczc-jbxx-qx!makeDocument.action'
  });
  win.show();
}


function printcz(templateCode, printTemplateCode){
  var busEntityKey = document.forms[0].id.value;
  var taskInstDbid = Ext.getCmp('WF_TOOLBAR').taskInstDbid;
  if(busEntityKey != null && busEntityKey != '' && taskInstDbid != null){
    var url = '${ctx}/yw-yn-jzfqwczc-jbxx-qx!printcz.action?taskInstDbid=' + taskInstDbid + '&id='+busEntityKey + '&templateCode=' + templateCode + '&busFormPrintCode=' + printTemplateCode;
    openCenterWindow(url, 1050, 650);
  }
}

function openAttache(url) {
  window.open(url);
}

function saveOpinion() {
    var jbrxckcTxt = document.getElementById('jbrxckcJudgmentTxt_ynczz');
    var jbhcTxt = document.getElementById('jbhcJudgmentTxt_ynczz');
    var szTxt = document.getElementById('szJudgmentTxt_ynczz');
    var fjzTxt = document.getElementById('fjzJudgmentTxt_ynczz');
    
    
    var inputObj, divobj;
    if (jbrxckcTxt && !jbhcTxt && !szTxt && !fjzTxt) {
      inputObj = jbrxckcTxt; divobj = document.getElementById('jbrxckcJudgment');
    } else if (!jbrxckcTxt && jbhcTxt && !szTxt && !fjzTxt) {
      inputObj = jbhcTxt; divobj = document.getElementById('jbhcJudgment');
    }else if (!jbrxckcTxt && !jbhcTxt && szTxt && !fjzTxt) {
      inputObj = szTxt; divobj = document.getElementById('szJudgment');
    }else if (!jbrxckcTxt && !jbhcTxt && !szTxt && fjzTxt) {
      inputObj = fjzTxt; divobj = document.getElementById('fjzJudgment');
    }
    
    
    if (!inputObj || inputObj.value == '') return;
    
    Ext.Ajax.request({
      method:'post',
      url:'${ctx}/wf!saveTaskOpinion.action',
      params:{
        'instance.taskInstDbid': WF_CONFIG.taskInstDbid,
        'instance.handleComments': inputObj.value
      },
      success:function(){
      changeOpinion(inputobj.value, divobj);
        inputobj.value = '';
      },
      scope:this
    });
}

function inputJudgment(index) {
    var divid = '', inputid = '';
    switch(index) {
        case 'A': divid = 'jbhcJudgment'; inputid = 'jbhcJudgmentTxt_ynczz'; break;
        case 'B': divid = 'jbrxckcJudgment'; inputid = 'jbrxckcJudgmentTxt_ynczz'; break;
        case 'C': divid = 'szJudgment'; inputid = 'szJudgmentTxt_ynczz'; break;
        case 'D': divid = 'fjzJudgment'; inputid = 'fjzJudgmentTxt_ynczz'; break;
    }
    var divobj = document.getElementById(divid);
    var inputobj = document.getElementById(inputid);
    if (divid == '' || !divobj) {
        alert('参数错误！');
        return;
    }
    if (inputobj.value == '') { alert('请输入意见!'); return; }
    Ext.Ajax.request({
      method:'post',
      url:'${ctx}/wf!saveTaskOpinion.action',
      params:{
        'instance.taskInstDbid': WF_CONFIG.taskInstDbid,
        'instance.handleComments': inputobj.value
      },
      success:function(){
        changeOpinion(inputobj.value, divobj);
        inputobj.value = '';
      },
      scope:this
    });
}

function changeOpinion(opinion, divobj) {
  var userOpinion = document.getElementById('userOpinion');
  if (userOpinion) {
    userOpinion.innerHTML = opinion + '<br>&nbsp;&nbsp;&nbsp;&nbsp;${CurrUserName}&nbsp;&nbsp;' + new Date().format('yyyy-MM-dd hh:mm:ss');
  } else {
    divobj.style.color = '#009966';
    divobj.innerHTML = opinion + '<br>&nbsp;&nbsp;&nbsp;&nbsp;${CurrUserName}&nbsp;&nbsp;' + new Date().format('yyyy-MM-dd hh:mm:ss');
  }
}


function writeJudgment(index) {
    var divid = '';
    switch(index) {
        case 'A': divid = 'jbhcJudgment'; break;
        case 'B': divid = 'jbrxckcJudgment'; break;
        case 'C': divid = 'szJudgment'; break;
        case 'D': divid = 'fjzJudgment'; break;
    }
    var divobj = document.getElementById(divid);
    if (divid == '' || !divobj) {
        alert('参数错误！');
        return;
    }
    var win = new Ext.ux.wf.WfOpinionWin({
        taskInstDbid: Ext.getCmp('WF_TOOLBAR').taskInstDbid
    });
    win.show();
    win.on('complete', function (opinion) {
        divobj.innerHTML = opinion + '<br>&nbsp;&nbsp;&nbsp;&nbsp;${CurrUserName}&nbsp;&nbsp;' + new Date().format('yyyy-MM-dd hh:mm:ss');
    });
}

//制文
 function makeDoc(){
  var win = new Ext.ux.wf.WfSelRedHeadFile({
    url: '/yw-yn-jzfqwczc-jbxx-qx!makeDocument.action'
  });
  win.show();
}

Ext.onReady(function(){
	$('input[type="checkbox"]').attr("disabled","disabled");
    var id_ = document.forms[0].id.value;
    var acceptNo_ = document.forms[0].acceptNo.value;
    if (id_ == '') {
      if (Ext.getCmp('WF_PRINT')) Ext.getCmp('WF_PRINT').setDisabled(true);
    }
    var centerTabPanel = Ext.getCmp('centerPanel');
    
    
	if (!<wf:hasPriv activities="jbrsl,jbrxckc,jbrcs,jbrfs,cksa" />) {
	   var urls="${ctx}/yw-com-sjcllist!ywList.action?tplcode=${templateCode}&ajid=${id}&qyid=${qyid}&isUpdate=false";
	   document.frames["sjcl_iframe"].location.href=urls;
	}
	
	if (!<wf:hasPriv activities="jbrsl,jbrxckc,jbrcs,jbrfs,cksa" />) {
		for (var i = 0; i < document.forms[0].elements.length; i++) {
	  	var element = document.forms[0].elements[i];
	    	if(element.isHide){
	        	if(element.type =='checkbox'|| element.type=='radio' || element.type=='button' ||element.name=='clsj') {
	            	element.disabled=true; 
	        	}else{
	            	element.readOnly= true; 
	            }	         
	         }
	 	}
	}
	 
    var tabPanel = new Ext.TabPanel({
        id: 'YwYnJzFqwczcJbxxTpanel',
        renderTo: 'tpanel',
        activeTab: 0,
        border: false,
        height: centerTabPanel.getHeight(),
        enableTabScroll: true,
        defaults: {autoScroll: true},
        items: [
            //new Ext.Panel({title: '基本信息', tabCls: 'right-tab', contentEl: 'tpanel01', border: false}),
            //new Ext.Panel({title: '车辆信息列表', tabCls: 'right-tab', contentEl: 'tpanel05', border: false}),
            //new Ext.Panel({title: '呈批表', tabCls: 'right-tab', contentEl: 'tpanel02', border: false}),
            //new Ext.Panel({title: '收件材料', tabCls: 'right-tab', contentEl: 'tpanel03', border: false}),
            //new Ext.Panel({title: 'WEBGIS', tabCls: 'right-tab', contentEl: 'tpanel04', border: false})
        ],
        listeners: {
            remove: function(tp, c) {
                c.hide();
            },
            afterlayout: function(c) {
                c.strip.setWidth(c.stripWrap.getWidth() - 2);
            },
            tabchange : function (tpanel, p) { 
                if(p.title=="车辆信息列表")
                {
                    findByQyid();
                }
            }
        }
    });
    
    var cpbPanel = new Ext.Panel({id: 'cpbPanel', title: '呈批表', tabCls: 'right-tab', contentEl: 'tpanel02', border: false, disabled: id_ == '' ? true : false});
    var jbxxPanel = new Ext.Panel({title: '申请表', tabCls: 'right-tab', contentEl: 'tpanel01', border: false});
    var clxxPanel = new Ext.Panel({id:'clxxPanel', title: '车辆信息列表', tabCls: 'right-tab', contentEl: 'tpanel05', border: false, disabled: id_ == '' ? true : false});
      var bjgzPanel = new Ext.Panel({title: '补交告知表', tabCls: 'right-tab', contentEl: 'tpanel00', border: false}); 
   
    if (!<wf:hasPriv activities="cksa" />) {
        tabPanel.add(new Ext.Panel({id: 'gisPanel', title: 'WEBGIS', tabCls: 'right-tab', contentEl: 'gis_tpanel', border: false, disabled: id_ == '' ? true : false}));
    }
    /**if (<wf:hasPriv activities="jbrspyj,kzyj,fczyj,czyj,czgldsh,wfgldsh,wzgldsp,jbsj,dzgz,czgldyqsh,wfgldyqsp,wzgldyqsh,jbrslyqbl" />) {//1
        tabPanel.add(new Ext.Panel({id: 'gisPanel', title: 'WEBGIS', tabCls: 'right-tab', contentEl: 'tpanel04', border: false, disabled: id_ == '' ? true : false}));
    }*/
    
 //   if (<wf:hasPriv activities="cksa,jbrspyj,kzyj,fczyj,czyj,jbrxckc,czsp,czgldsh,wfgldsh,wzgldsp,jbsj,dzgz,czgldyqsh,wfgldyqsp,wzgldyqsh,jbrslyqbl" />) {//2
        tabPanel.add(new Ext.Panel({id: 'sjclPanel', title: '收件材料', tabCls: 'right-tab', contentEl: 'tpanel03', border: false, disabled: id_ == '' ? true : false}));
  //  }
    
 //   if (<wf:hasPriv activities="cksa,jbrspyj,kzyj,fczyj,czyj,jbrxckc,czsp,czgldsh,wfgldsh,wzgldsp,jbsj,dzgz,czgldyqsh,wfgldyqsp,wzgldyqsh,jbrslyqbl" />) {//1
        tabPanel.add(clxxPanel);
 //   }
    
    if (!<wf:hasPriv activities="cksa" />) {
        tabPanel.add(new Ext.Panel({title: '检查表', tabCls: 'right-tab', contentEl: 'tpanel08', border: false}));
    }
 
 //   if (<wf:hasPriv activities="cksa,jbrspyj,kzyj,fczyj,czyj,jbrxckc,czsp,czgldsh,wfgldsh,wzgldsp,jbsj,dzgz,czgldyqsh,wfgldyqsp,wzgldyqsh,jbrslyqbl" />) {//2
        tabPanel.add(jbxxPanel);
 //   }
    
 //   if (<wf:hasPriv activities="jbrspyj,kzyj,fczyj,czyj,jbrxckc,czsp,czgldsh,wfgldsh,wzgldsp,jbsj,dzgz,czgldyqsh,wfgldyqsp,wzgldyqsh,jbrslyqbl" />) {//2
  //      tabPanel.add(cpbPanel);
 //   }
    if (<wf:hasPriv activities="jbrsl" />) {
    	tabPanel.add(bjgzPanel);
    }
    if (<wf:hasPriv activities="jbrsl,jbrxckc,jbrcs,jbrfs,kzsh,fczsp,szsp,fjzsp,sf,ckfsgz,jbrbj" />) {
        tabPanel.add(cpbPanel);
        tabPanel.setActiveTab(cpbPanel);
    } else {
        //ywPanel.add(cpbPanel);
        tabPanel.setActiveTab(jbxxPanel);
    }
   
    tabPanel.doLayout(true);
});


//打印证书
function printxkz(){
 	var id = document.forms[0].id.value;
  	openCenterWindow(ctx + '/yw-yn-jzfqwczc-jbxx!preViewXkz.action?id='+id+"&taskId="+parent.WF_CONFIG.taskInstDbid, 1100, 650);
}

//盖章许可证书
function xkzgz(){
 	var id = document.forms[0].id.value;
  	openCenterWindow(ctx + '/yw-yn-jzfqwczc-jbxx!gzViewXkz.action?id='+id+"&taskId="+parent.WF_CONFIG.taskInstDbid, 1100, 650);
}
</script>
</head>

<body>

<form action="yw-yn-jzfqwczc-jbxx-qx!save.action" method="post">
  <!---------------- 隐藏域区域 开始 ----------------->
  <input id="hid" type="hidden" name="id" value="${id}" />
  <input type="hidden" id="qyid" name="qyid" value="${qyid}" />
    <input type="hidden" id="checkDate" value="<s:date name='checkCarDate' format="yyyy-MM-dd"/>" />
  <input type="hidden" id="checkPerson"  value="${checkCarPerson}" />
  <input type="hidden" id="checkLeader"  value="${checkCarLeader}" />
  <input type="hidden" id="templateCode"  value="${templateCode}" />
  <input type="hidden" id="approvalNo" name="approvalNo" value="${approvalNo}"/>
  <input id="pageNo" type="hidden"/>
  <!---------------- 隐藏域区域 结束 ----------------->
<div id="tpanel"></div>

<div style="display:none">
<div id="tpanel01" align="center">
  <%@ include file="YwYnJzfqwczcJbxx-sqb.jsp" %>
</div>
<div id="tpanel02" align="center">
  <%@ include file="YwYnJzfqwczcJbxxqx-cpb.jsp" %>
</div>
<div id="tpanel03" align="center">
	<iframe id="sjcl_iframe" src="${ctx}/yw-com-sjcllist!ywList.action?tplcode=${templateCode}&ajid=${id}&qyid=${qyid}" scrolling="auto" frameborder="0" width="100%" height="100%">
  	</iframe>
</div>
<div id="tpanel04">
  <iframe src="${ctx}/qyzz/test.jsp" scrolling="auto" frameborder="0" width="100%" height="100%"></iframe>
</div>
<div id="tpanel05" align="center" >
  
</div>

<div id="tpanel06">
    <%@ include file="../../ywcmn/AddBus.jsp" %>
</div>
<div id="tpanel07" align="center">

</div>
<div id="tpanel00" align="center"><%@ include file="../common/YwYnJzfqwczzXn-bjgz.jsp" %></div>

<div id="tpanel08" align="center">
    <%@ include file="YwYnJzfqwczcJbxx-jcb.jsp" %>
</div>

<div id="gis_tpanel">
  <iframe src="${ctx}/flex/index.html" scrolling="auto" frameborder="0" width="100%" height="100%"></iframe>
</div>
</div >
	
</form>

<div style="display:none">
  <input id="attacheBrow" type="file" />
</div>
</body>
</html>
